


#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    vector<int> getRow1(int rowIndex)
    {
        if (0 == rowIndex)
            return { 1 };

        if (1 == rowIndex)
            return { 1, 1 };

        vector<vector<int>> vv;
        vv.resize(rowIndex + 1);
        vv[0].resize(1, 1);
        vv[1].resize(2, 1);

        for (int i = 2; i < rowIndex + 1; ++i)
        {
            vv[i].resize(i + 1, 1);
            for (int j = 1; j < vv[i].size() - 1; ++j)
            {
                vv[i][j] = vv[i - 1][j] + vv[i - 1][j - 1];
            }
        }

        return vv[rowIndex];
    }

    vector<int> getRow2(int rowIndex)
    {
        if (0 == rowIndex)
            return { 1 };
        if (1 == rowIndex)
            return { 1 , 1 };

        vector<vector<int>> vv;
        vv.resize(rowIndex + 1);

        for (int i = 0; i < rowIndex + 1; ++i)
        {
            vv[i].resize(i + 1, 1);
            for (int j = 1; j < vv[i].size() - 1; ++j)
            {
                vv[i][j] = vv[i - 1][j] + vv[i - 1][j - 1];
            }
        }

        return vv[rowIndex];
    }

    vector<int> findAnagrams(string s, string p)
    {
        int sz = s.size(), pz = p.size();

        if (sz < pz)
            return {};

        vector<int> ans;
        vector<int> cnt_p(26);
        int end = sz - 1 - (pz - 1);

        for (const auto& ch : p)
        {
            ++cnt_p[ch - 'a'];
        }

        for (int i = 0; i <= end; ++i)
        {
            vector<int> cnt_s(26);
            for (int j = i; j <= i + pz - 1; ++j)
            {
                ++cnt_s[s[j] - 'a'];
            }

            if (cnt_p == cnt_s)
                ans.push_back(i);
        }

        return ans;
    }

    template<class Container>
    void Print(const Container& con)
    {
        for (auto& x : con)
        {
            cout << x << " ";
        }
        cout << endl;
    }
};

void Test1()
{
    int rowIndex = 3;

    Solution().Print(Solution().getRow2(rowIndex));
#if 0
    vector<int> v = { 1, 2, 3 };
    Solution().Print(v);
#endif
}

int main()
{
    Test1();


	return 0;
}